package com.prim.demo.t_spring_boot_mybatis.service.impl;

import com.prim.demo.t_spring_boot_mybatis.mapper.StuMapper;
import com.prim.demo.t_spring_boot_mybatis.pojo.Stu;
import com.prim.demo.t_spring_boot_mybatis.service.StuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StuServiceImpl implements StuService {
    @Autowired
    private StuMapper stuMapper;

    @Override
    public void save() {
        Stu stu = new Stu();
        stu.setName("test-1");
        stu.setAge(32);
        stuMapper.save(stu);
    }

    @Override
    public void update(int id) {
        Stu stu = new Stu();
        stu.setId(id);
        stu.setName("update-1");
        stu.setAge(28);
        stuMapper.update(stu);
    }

    @Override
    public void delete(int id) {
        stuMapper.delete(id);
    }

    @Override
    public Stu getOne(int id) {
        return stuMapper.selectOne(id);
    }

    @Override
    public List<Stu> getAll() {
        return stuMapper.selectAll();
    }
}
